package com.infoguia;


import java.util.List;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
 
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;
import com.infoguia.util.Constants;
import com.infoguia.util.MyOverlay;


public class Map extends MapActivity{


	private MapView mapView;
 
	private int latitudeE6;
	private int longitudeE6;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.maps);
 
        mapView = (MapView) findViewById(R.id.mapView);
        mapView.setBuiltInZoomControls(true);
 
        List mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.icon_geo);
		MyOverlay itemizedOverlay = new MyOverlay(drawable, this);
 
		Bundle extras = getIntent().getExtras();
		String geo = extras != null ? extras.getString("GEO")
				: null;
		
		String geos[] = geo.split(",");
		
		latitudeE6 = Integer.parseInt(geos[0]);
		longitudeE6 = Integer.parseInt(geos[1]);
		
		GeoPoint point = new GeoPoint(latitudeE6, longitudeE6);
		OverlayItem overlayitem = new OverlayItem(point, "Infoguia",
				"Esta es la empresa Seleccionada");
 
		itemizedOverlay.addOverlay(overlayitem);
		mapOverlays.add(itemizedOverlay);
 
		MapController mapController = mapView.getController();
 
		mapController.animateTo(point);
		mapController.setZoom(6);
		this.goHome();
 
    }
 
	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
	
	public void goHome() {

		ImageView home = (ImageView) findViewById(R.id.home);

		home.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(Map.this, StartActivity.class);
				startActivityForResult(i, 1);
			}
		});

	}
}
